/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package io;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * 
 * @author xiaohui
 */
public class HandleFiles {

	/**
	 * 
	 * @param filePath
	 * @return
	 * @throws Exception
	 */
	public static ArrayList<String[]> readRouteFile(File filePath)
			throws Exception {
		ArrayList<String[]> res = new ArrayList<String[]>();
		FileInputStream fstream = new FileInputStream(filePath);
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));

		String strLine;
		br.readLine(); // remove header

		int j = 0;
		while ((strLine = br.readLine()) != null) {
			String[] arr = strLine.split(" ");
			String[] tloc = new String[]{arr[15], arr[16], arr[17]};
			res.add(tloc);
			j++;
		}

		in.close();
		System.err.println("readRouteFile: Read " + j + " lines");

		// db.closeConnection();
		return res;
	}

	

}
